package site;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ArticleAfficheServlet
 */
public class ArticleAfficheServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	@EJB
	ArticleManager am ;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ArticleAfficheServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int i = Integer.parseInt(request.getParameter("artc"));
		getServletContext().setAttribute("idArticle",i);
		
		request.setAttribute("Titre",am.listeTitre().get(i-1));
		request.setAttribute("Date",am.listeDate().get(i-1));
		request.setAttribute("Contenu",am.listeContenu().get(i-1));
		request.setAttribute("image", am.listeImage().get(i-1));
		request.getRequestDispatcher("articleComplet.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			doGet(request,response);
	}

}
